<script lang="ts" setup>
import SuperButton from "@/module/button/superButton.vue";
import {ref} from "vue";
import {ParkingLogApi} from "@/api/log/ParkingLogApi.ts";
import {ElMessageBox} from "element-plus";
import {ParkingLogBo} from "@/dto/Log/ParkingLog.ts";


const parkingLogApi = ref(new ParkingLogApi())

function simulateIn(){
    simulate("模拟入库",async (val)=>{
        let bo = new ParkingLogBo(val)
        await parkingLogApi.value.in(bo)
    })
}
function simulateOut(){
    simulate("模拟出库",async (val)=>{
        let bo = new ParkingLogBo(val)
        await parkingLogApi.value.out(bo)
    })
}

function simulate(simulateText:string,fn:Function){
    ElMessageBox.prompt(simulateText,"模拟",{
        cancelButtonText: '取消',
        confirmButtonText: "确定"
    }).then(async (val)=>{
        fn(val.value)
    })
}
</script>

<template>
    <el-row>
        <el-col :span="12">
            <super-button
                    title="模拟入库"
                    type="primary"
                    style="height: 500px;width: 100%;font-size: 50px"
                    @click="simulateIn"
            />
        </el-col>
        <el-col :span="12">

            <super-button
                    title="模拟出库"
                    type="info"
                    style="height: 500px;width: 100%;font-size: 50px"
                    @click="simulateOut"
            />
        </el-col>
    </el-row>
</template>

<style scoped>

</style>